package com.lczyfz.wisdom.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * Package：com.lczyfz.wisdom.modules.sys.config
 * Effect:
 * Author: HuangBing
 * Time: 2018/8/8 12:39
 */
@EnableWebMvc
@EnableSwagger2
@ComponentScan(basePackages={"com.lczyfz.wisdom.modules.sys.vueweb", "com.lczyfz.wisdom.modules.platform.vueweb", }) //需要扫描的包路径
@Configuration
public class SwaggerConfig extends WebMvcConfigurationSupport{

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage(""))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("联创智云信息科技有限公司")
                .termsOfServiceUrl("")
                .contact(new Contact("数据建模项目开发组", "http:www.lczyfz.com", "info@lczyfz.com"))
                .version("v1.1")
                .build();
    }
}